unit DM;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ImgList, Menus, Db, IfxCustomDataset, IfxQuery, IfxConnection, ActnList,
  IfxVisualMonitor, IfxFileMonitor, IfxMonitor;

type
  TfrmDM = class(TDataModule)
    ImageList: TImageList;
    OpenDialog: TOpenDialog;
    SaveDialog: TSaveDialog;
    IfxConnection: TIfxConnection;
    IfxQuery: TIfxQuery;
    DataSource: TDataSource;
    IfxCompositMonitor: TIfxCompositMonitor;
    IfxFileMonitor: TIfxFileMonitor;
    IfxVisualMonitor: TIfxVisualMonitor;
    procedure IfxConnectionAfterConnect(Sender: TObject);
    procedure IfxConnectionAfterDisconnect(Sender: TObject);
    procedure IfxConnectionTimeOut(Status: TIfxTimeOutStatus);
    procedure IfxQueryAfterOpen(DataSet: TDataSet);
    procedure IfxQueryAfterClose(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmDM: TfrmDM;

implementation

uses Main;
  
{$R *.DFM}

const
  AppConnected = 'Application successfully connected to the database server';
  AppDisconnected = 'Application successfully disconnected from the database server';

procedure TfrmDM.IfxConnectionAfterConnect(Sender: TObject);
begin
  MessageDlg(AppConnected, mtInformation, [mbOK], 0);
  frmMain.InitControls(True);
end;

procedure TfrmDM.IfxConnectionAfterDisconnect(Sender: TObject);
begin
  MessageDlg(AppDisconnected, mtInformation, [mbOK], 0);
  frmMain.InitControls(False);
end;

procedure TfrmDM.IfxConnectionTimeOut(Status: TIfxTimeOutStatus);
begin
  Application.ProcessMessages;
end;

procedure TfrmDM.IfxQueryAfterOpen(DataSet: TDataSet);
begin
  frmMain.labelResults.Enabled := True;
  frmMain.DBGrid.Enabled := True;
end;

procedure TfrmDM.IfxQueryAfterClose(DataSet: TDataSet);
begin
  frmMain.labelResults.Enabled := False;
  frmMain.DBGrid.Enabled := False;
end;

end.

